#include <birdwater.h>
#include <Arduino.h>

int TaskBumpTable[][2] = {
  //
  1, 2,
  1, 0
};
int TaskMoveTable[][2] = {
  //
  1, 2, 100, 0
};

BirdWaterConfig g_BirdWaterConfig;
MQTT_WORKSTATE g_MqttWorkState;


/*
返回值：状态机
输入：cmd,
输出：
bump:0,1
move:-100:100
*/
void BirdWaterLoop(BirdWaterConfig *config) {

  birdwaterSS(config);

  //浇水控制
  if (config->g_WorkState == WORK_STATE_IDLE) {
    config->g_PumpOn = 0;
    config->g_MoveSpeed = 0;
  } else if (config->g_WorkState == WORK_STATE_WORK) {
    config->g_PumpOn = 1;
    config->g_MoveSpeed = 0;
  } else if (config->g_WorkState == WORK_STATE_TEST) {
    //birdwaterTest(cmd);

  } else if (config->g_WorkState == WORK_STATE_TIMESET) {
    config->g_PumpOn = 0;
    config->g_MoveSpeed = 0;
  } else if (config->g_WorkState == WORK_STATE_SLEEP) {
    config->g_PumpOn = 0;
    config->g_MoveSpeed = 0;
  }
}
